Skip to content

Conversation

@LB--
Copy link
Member

@LB-- LB-- commented Jun 4, 2013

@LB-- LB-- mentioned this pull request Jun 4, 2013
@LB--
Copy link
Member Author

LB-- commented Jun 4, 2013

I am able to generate makefiles for clang with

cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-std=c++11 -DSTATIC_BUILD=1 . && mingw32-make

However, it seems that the includes are off since it can't find SFML or boost on #include statements.

@LB--
Copy link
Member Author

LB-- commented Jun 4, 2013

OK, I've fixed it to have proper include paths - it now compiles correctly.

@LB--
Copy link
Member Author

LB-- commented Jun 4, 2013

The only downside is that it takes nightmarishly long because it compiles each *.cpp file separately - is there a way we can get it to combine all *.cpp files together in one invocation of the compiler? (Obviously the *.c files would still be separate)

@ghost ghost assigned naraku9333 Jun 4, 2013
@naraku9333
Copy link
Member

Do we really need SFML and Boost in the project tree? Users/developers should have them installed in their prefered location and set the root in the cmake options.

@Thumperrr
Copy link
Member

The libraries in the project tree are just links to the sfml and boost repositories. Users can download them or not download them by choice (if they already have them)

@naraku9333
Copy link
Member

The changes to CMakeLists.txt expect SFML to be in ChessPlusPlus/lib/SFML. Also, is it possible to init and pull just the json-parser module?

@Thumperrr
Copy link
Member

Oh. That shouldn't be then.
And yes there is. From the command line: git submodule init lib/json-parser ; git submodule update lib/json-parser

-Stephen Hall

On Jun 4, 2013, at 6:32 PM, "Sean Vogel" notifications@github.com wrote:

The changes to CMakeLists.txt expect SFML to be in ChessPlusPlus/lib/SFML. Also, is it possible to init and pull just the json-parser module?


Reply to this email directly or view it on GitHub.

@naraku9333
Copy link
Member

LB said:

The only downside is that it takes nightmarishly long because it compiles each *.cpp file separately - is there a way we can get it to combine all *.cpp files together in one invocation of the compiler? (Obviously the *.c files would still be separate)

How slow is it? It takes roughly the same amount of time to compile for me as with g++ directly.

@LB--
Copy link
Member Author

LB-- commented Jun 5, 2013

Do we really need SFML and Boost in the project tree?

The paths can be overridden, right?

Also, is it possible to init and pull just the json-parser module?

From the command line, just git clone and don't use the --recursive option, then do as @Thumperrr said.

How slow is it?

It takes the same amount of time to compile one file as it does to compile them all at once.

@Thumperrr
Copy link
Member

The paths can be overridden, right?

There shouldn't be a default for them imo. We should use cmake's find package function to search for SFML/Boost (on other OSs this works much better than in Windows). If the packages can't be found then the user should set the location.

@LB--
Copy link
Member Author

LB-- commented Jun 5, 2013

I do want to use the package finder but I don't know how to use it. I still think it should look in ./lib/ first - the whole point of using submodules is that they link to a specific commit or version of the project they reference, meaning that if they init the submodules they are guaranteed to get the version that worked for us.

@ghost
Copy link

ghost commented Jun 5, 2013

To use Cmake find_package for SFML you can use this module (Save it in a
new directory called cmake_modules)
https://github.com/LaurentGomila/SFML/blob/master/cmake/Modules/FindSFML.cmake

You can then use that module to find SFML with something like this

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML 1.6 REQUIRED system window graphics network audio)
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})

First we say where we placed the FindSFML.cmake module.

We then request CMake to search the system for the specified modules
(Included them all here)

Then we tell CMake to link to the libraries.

On Wed, Jun 5, 2013 at 9:13 AM, LB-- notifications@github.com wrote:

I do want to use the package finder but I don't know how to use it. I
still think it should look in ./lib/ first - the whole point of using
submodules is that they link to a specific commit or version of the project
they reference, meaning that if they init the submodules they are
guaranteed to get the version that worked for us.


Reply to this email directly or view it on GitHubhttps://github.com//pull/42#issuecomment-18978053
.

@LB--
Copy link
Member Author

LB-- commented Jun 5, 2013

zereo's post but with fixed formatting:

To use Cmake find_package for SFML you can use this module (Save it in a
new directory called cmake_modules)
https://github.com/LaurentGomila/SFML/blob/master/cmake/Modules/FindSFML.cmake

You can then use that module to find SFML with something like this

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()

Zereo EDIT: Updated to better code from the previous one, grabbed this code from here since it suits our purposes I believe https://github.com/LaurentGomila/SFML/wiki/Tutorial%3A-Build-your-SFML-project-with-CMake might just need a few minor changes to search in the ./lib/ folder first for SFML then maybe search the others as a fallback.

First we say where we placed the FindSFML.cmake module.

We then request CMake to search the system for the specified modules
(Included them all here)

Then we tell CMake to link to the libraries if it is found

@ghost
Copy link

ghost commented Jun 5, 2013

Sorry I wasn't able to get through with the CMake list had a very busy workload lately, but thank you Naraku for writing one up.

Also we can use find_package for BOOST even easier since it is a more common library

# Can define whatever version we require then whatever libraries we require from boost.
find_package(Boost 1.34.0 REQUIRED system filesystem)
if(Boost_FOUND)
  include_directories(${Boost_INCLUDE_DIRS})
  target_link_libraries(${EXECUTABLE_NAME} ${Boost_LIBRARIES})
endif()

@LB--
Copy link
Member Author

LB-- commented Jun 5, 2013

I'm working on adding these in ;)

@LB--
Copy link
Member Author

LB-- commented Jun 5, 2013

@Zereo it won't work, it requires SFML to actually be installed, which is completely different from having the source code of SFML. (not to mention completely impossible on Windows)

@ghost
Copy link

ghost commented Jun 5, 2013

Hmm I'll dink around with the file when I get home from work a bit and see if I can get the SFML one up and running with Naraku's CMake file.

@Thumperrr
Copy link
Member

@LB--

find_package(Boost 1.35.0 REQUIRED system filesystem)
if(Boost_FOUND)
--link
else
--specify manually
endif()

We want to use find_package (even if it won't work on windows).

@ghost
Copy link

ghost commented Jun 5, 2013

Ideally we all should have the correct version of SFML installed on our computers for our OS. So ideally the CMakelist should just search for SFML on the system. If the user developer that is running the CMakelist doesn't have SFML installed on their machine it is their fault and they need to fix it not us in my opinion.

All that find_package() is doing is looking for where SFML is installed on the machine (Or in some cases the projects come with pre-built libraries for systems) then linking them libraries to the executable and including the include directories.

I am also not really understanding how it is completely impossible to have SFML installed on a windows machine...

@LB--
Copy link
Member Author

LB-- commented Jun 5, 2013

The problem is that it looks for SFML.frameworks in a variety of paths that are not valid paths on Windows. I don't understand why it can't just find a normal SFML directory.

As long as it can build for me, you can implement it however you want - if your method fails have it fall back on the current method.

@Thumperrr
Copy link
Member

I am also not really understanding how it is completely impossible to have SFML installed on a windows machine...

Windows doesn't have default library paths like OS x and linux machines do. So the FindSFML module won't do anything useful.

if your method fails have it fall back on the current method.

That's the plan.

@ghost
Copy link

ghost commented Jun 5, 2013

Well one option we could use would be to include a Windows SFML 2.0 Release inside our repo and just dump all the other library files for other OS in along with the Windows libs and then set the CMakelist to search that directory for the library files and include's. This would probably be easiest way I can think of because if we wanted to change out the version of SFML we would just have to replace the files in our repo and update one spot in the CMakeList.

we can easily just set where it searches by doing

# Set the path to look for SFML in. I just put in a standard path can to show for a example
set(SFMLDIR "${CMAKE_SOURCE_DIR}/lib/SFML-2.0")

# Set where to look for the find_package(SFML) module
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})

#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()

At least I believe that should work, I am still a novice on this sort of thing especially GITHUB and GIT which I am still struggling to learn. 

@naraku9333
Copy link
Member

I was looking into find_package last night and will continue tonight, but I really don't see a problem with just setting SFMLROOT, which will probably be necessary on windows anyway. Users should be responsible for installing dependencies.

@LB-- I'll look into incremental build.

@naraku9333
Copy link
Member

Are you able to build and link with MinGW?
I just tested on a fresh install of nuwen and sfml without any problems using

cmake -G"Unix Makefiles" -DSTATIC_BUILD=TRUE -DSFML_ROOT="C:\Program Files (x86)\SFML" -DBOOST_ROOT="C:\MinGW"

@LB-- LB-- closed this Oct 4, 2013
@LB-- LB-- reopened this Oct 4, 2013
@LB--
Copy link
Member Author

LB-- commented Oct 4, 2013

No, I get crazy linker errors that I'm trying to figure out.

As for my own fork, there's a bug in MinGW with using declarations causing valid code not to compile, so I have no idea.

@naraku9333
Copy link
Member

Its weird you are having so many problems with nuwen and I'm not. Can you try with a fresh download of nuwen and build of sfml?

@LB--
Copy link
Member Author

LB-- commented Oct 4, 2013

Can you try with a fresh download of nuwen and build of sfml?

That's what I did for that test...

@LB--
Copy link
Member Author

LB-- commented Oct 7, 2013

@naraku9333 I rebuilt SFML with MinGW and am using CMake with MinGW, and now everything runs and compiles except when it gets to be times to link. I get this error:

make[2]: *** No rule to make target `C:/Program Files (x86)/SFML/lib/sfml-graphi
cs-s.lib', needed by `chesspp.exe'.  Stop.
make[1]: *** [CMakeFiles/chesspp.dir/all] Error 2
make: *** [all] Error 2

It's still looking for .lib, but in SFML/lib/ there are .a files. I have tried both "MinGW Makefiles" and "Unix Makefiles" and both try to find .lib instead of .a, yet both generate .a files when I build SFML.

Not only that, but it's actually got them listed as build targets - it's trying to build those files, not just use them.

As for the -std=c++11;=std=c++11 thing, I found the issue: I was specifying -DCMAKE_CXX_FLAGS=-std=c++11 but in CMakeLists.txt you use list(APPEND CMAKE_CXX_FLAGS "-std=c++11") which instead of separating with a space separates with a semi-colon. This will cause problems no matter what I -DCMAKE_CXX_FLAGS= to

@LB--
Copy link
Member Author

LB-- commented Oct 7, 2013

Actually, I have no idea what I changed, but it's working now - now I just need for fix the linker errors specific to my code. EDIT: Yes! I can finally compile and link! Now to start debugging...

(The -std=c++11;=std=c++11 thing mentioned above will still be an issue)

@LB-- LB-- mentioned this pull request Oct 7, 2013
@LB--
Copy link
Member Author

LB-- commented Oct 9, 2013

I think all main issues have been resolved - I'm going to go ahead and merge this as any more issues should be minor.

LB-- added a commit that referenced this pull request Oct 9, 2013
@LB-- LB-- merged commit 6db7196 into master Oct 9, 2013
@LB-- LB-- deleted the cmake branch October 9, 2013 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmake Centralized makefile/compilation

5 participants